package Collection; /**
 * 项目名称:写一个方法能处理 List<Dog> List<Cat>,但不能处理List<Person>
 *
 * @Author: 夏国倩
 * @Date: 2023/9/20 16:17
 * @Copyright
 */
/*
package demo.Collect;
import demo.Interface1.A;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
public class Collection7 {
    */
/*
    List.of(元素1，元素2，元素3，....)给集合一次性添加多个元素
    前提：当集合中存储的元素个数已经确定了，不再改变的时候
     *//*

    public static void main(String[] args) {
        test1(getDogList());
        //test1(getPersonList());
        List<Cat2> catList = getCatList();
        catList.add(1, new Cat2());
        catList.set(1, new Cat2());
        test1(catList);
    }

    private static void test1(List<? extends Animal> a) {
        for (Object o : a) {
            System.out.println(o);
        }
    }

    private static List<Person2> getPersonList() {
    */
/*
    List<Cat2> cat2s = new ArrayList<Cat2>();
    cat2s.add(new Cat2());
    cat2s.add(new Cat2());
    return cat2s;
    *//*

        return List.of(new Person2(), new Person2());
    }

    //创建Cat集合
    private static List<Cat2> getDogList() {
            */
/*
            List<Cat2> cat2s=new ArrayList<Cat2>();
            cat2s.add(new Cat2());
            cat2s.add(new Cat2());
            return cat2s;
            *//*

        return List.of(new Cat2(), new Cat2());
    }

    //创建Dog集合
    private static List<Dog2> getDogList() {
            */
/*
            List<Dog2> dog2s=new ArrayList<Dog2>();
            dog2s.add(new Dog2());
            dog2s.add(new Dog2());
            return dog2s;
            *//*

        return List.of(new Dog2(), new Dog2(), new Dog2());
    }
}

class Animal {
}

class Dog2 extends Animal {
}

class Cat2 extends Animal {
}

class Person2 {
}
*/
